package com.ysy.groovy.plugin;


import com.android.build.gradle.AppExtension;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;

import java.util.List;
import java.util.Map;
import java.util.Set;

class TestAopPlugin implements Plugin<Project> {
    @Override


    public void apply(Project target) {
        System.out.println("-------------11111");
        Map<Project, Set<Task>> allTasks = target.getAllTasks(true);
        Set<Project> projects = allTasks.keySet();
        for (Project defaultTask : projects) {
            System.out.println( "apply0: defaultTask.getName()="+defaultTask.getName());
            System.out.println( "apply1: defaultTask.getDefaultTasks().size()="+defaultTask.getDefaultTasks().size());
            Set<Task> tasks = allTasks.get(defaultTask);
            for (Task task : tasks) {
                System.out.println( "task= "+task.getName());
            }
            System.out.println( "apply2:tasks= "+tasks.size());
        }
        System.out.println("-------------22222");


        AppExtension byType = target.getExtensions().getByType(AppExtension.class);
        byType.registerTransform(new TestGroovyTransfrom());
    }
}
